package com.mt.course.service.impl;

import java.util.List;
import java.util.Map;


import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import com.mt.course.api.service.ICustomerExaminationTestLogService;
import com.mt.course.entity.CustomerExaminationTestLogEntity;
import com.mt.course.service.model.CustomerExaminationTestLogServiceModel;
import org.springframework.stereotype.Service;

@Service
public class CustomerExaminationTestLogServiceImpl implements ICustomerExaminationTestLogService {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CustomerExaminationTestLogServiceImpl.class);

    @Autowired
    private CustomerExaminationTestLogServiceModel customerExaminationTestLogServiceModel;

    public ServiceResult<CustomerExaminationTestLogEntity> findInfo(Map<String, Object> params) {
        ServiceResult<CustomerExaminationTestLogEntity> result = null;
        try {
            result = customerExaminationTestLogServiceModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<Integer> findTestedSum(Map<String, Object> params) {
        ServiceResult<Integer> result = null;
        try {
            result = customerExaminationTestLogServiceModel.selectTestedSum(params);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<List<CustomerExaminationTestLogEntity>> findList(Map<String, Object> params,
        PagerInfo<?> pagerInfo) {
        ServiceResult<List<CustomerExaminationTestLogEntity>> result =
            new ServiceResult<List<CustomerExaminationTestLogEntity>>();
        try {
            result = customerExaminationTestLogServiceModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }

        return result;
    }

    public ServiceResult<Integer> doInsert(CustomerExaminationTestLogEntity customerExaminationTestLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = customerExaminationTestLogServiceModel.insert(customerExaminationTestLogEntity);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdateRelate(CustomerExaminationTestLogEntity customerExaminationTestLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = customerExaminationTestLogServiceModel.updateRelate(customerExaminationTestLogEntity);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "编辑信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doDeleteById(Integer customerExaminationTestLogId) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = customerExaminationTestLogServiceModel.deleteByPrimaryKey(customerExaminationTestLogId);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][doDeleteById]：query doDeleteById occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "删除信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(CustomerExaminationTestLogEntity customerExaminationTestLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result =
                customerExaminationTestLogServiceModel.updateByPrimaryKeySelective(customerExaminationTestLogEntity);
        } catch (Exception e) {
            LOGGER.error("[CustomerExaminationTestLogServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "更新信息错误.");
        }
        return result;
    }

}
